<?php
	function alexaRank($domain)
	{
		$remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain);
		$search_for = '<POPULARITY URL';
		$part='';
		if ($handle = @fopen($remote_url, "r")) {
		while (!feof($handle)) {
		$part .= fread($handle, 100);
		$pos = strpos($part, $search_for);
		if ($pos === false)
		continue;
		else
		break;
		}
		$part .= fread($handle, 100);
		fclose($handle);
		}
		$str = explode($search_for, $part);
		$str = array_shift(explode('"/>', $str[1]));
		$str = explode('TEXT="', $str);
		return $str[1];
	}
	
	$source = file_get_contents('http://data.alexa.com/data?cli=10&dat=snbamz&url=jveo.net');
	var_dump($source);
	die;
	
	//Alexa Rank
	preg_match('/\<popularity url\="(.*?)" text\="([0-9]+)" source\="panel"\/\>/si', $source, $matches);
	$aresult = ($matches[2]) ? $matches[2] : 0;
	
	//Alexa Sites Linking in
	preg_match('/\<linksin num\="([0-9]+)"\/\>/si', $source, $cocok);
	$alinksin = ($cocok[1]) ? $cocok[1] : 0;
	
	echo 'Alexa Traffic Rank: '.$aresult.'<br>';
	echo 'Alexa Sites Linking In: '.$alinksin;
	
	
//echo "Alexa ranking: " . alexaRank("http://jveo.net");
?>